
from ronglian_sms_sdk import SmsSDK
accId = '8a216da87ba59937017bb10e4b0d0192'
accToken = '06ba0d6b70e44725a9337411a86c15f8'
appId = '8a216da87ba59937017bb10e4bf80198'
class CCP(object):
    '''发送验证码的单例类'''
    def __new__(cls, *args, **kwargs):
        # 没有_instance创建一个实例
        if not hasattr(cls,'_instance'):
            cls._instance=super(CCP,cls).__new__(cls, *args, **kwargs)
            # 初始化sdk,并赋给实例的属性，同生共死
            cls._instance.sdk = SmsSDK(accId, accToken, appId)
        # 有_instance就返回
        return  cls._instance
    def send_message(self,tid,mobile,datas):
        resp = self.sdk.sendMessage(tid, mobile, datas)
        print("resp:"+resp)
        resp=eval(resp)  #str转化成dict
        if resp.get('statusCode')=="000000":
            return 0
        else:
            return -1
if __name__=='__main__':
    result=CCP().send_message('1','17621623292',('杰哥你好呀','2'))
    print(result)